<?php

/**
 * Description of ContractController
 *
 * @author luigi.pastore
 * @created  25-gen-2012
 */
class ContrattiController extends Classes_Controller
{
    public function init()
    {
	$this->model_contract	    = new Classes_Contract;
	$this->model_live	    = new Classes_Live;

	// Edit...
	if( is_numeric( $id = $this->getParam( 'id' ) ) )
	{
	    // Fetch
	    $contract = $this->model_contract->fetchById( array( $id ) );
	    
	    if( empty( $contract ) )
		trigger_error( 'Nessun Contratto' );
	    
	    $this->contract = array_shift( $event );
	    
	    # Assegniamo i dati al layout
	    $this->layout->data = $this->contract;
	    $this->layout->contract_id = $this->contract['contract_id'];
	    
	    // Se sto editando precompilo la sessione
	    if( !empty( $this->contract ) AND empty( $_SESSION['Contract'] ) )
	    {
		# Formattiamo campi
		// ...

//		$_SESSION['Event']['Info'] = $this->event;
//		$_SESSION['Event']['Live'] = $this->event['event_live'];
	    }    
	}
    }

    public function indexAction()
    {
	$this->layout->content = array( 'script' => 'contratti/index' );
    }
}